package org.fing.edu.uy.esb.adaptative.ws.utils;

import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

public class MgrConfig {
	
	private static java.util.logging.Logger logger = Logger.getLogger(MgrConfig.class.getSimpleName());
	
	private static MgrConfig instance;
	private Properties properties;
	
	private MgrConfig() {
		InputStream is = this.getClass().getResourceAsStream("/META-INF/config.properties");
		properties = new Properties();
		try {
			properties.load(is);
		} catch (Exception ex) {			
			logger.log(Level.SEVERE, "Exception when initialized config file.", ex);
		}
	}
	
	public static synchronized MgrConfig getInstance() {
		if(instance == null) {
			instance = new MgrConfig();
		}
		return instance;
	}
	
	public String getProperty(String key){
		return properties.getProperty(key, "");
	}
	
	public String getProperty(String key, String defaulValue){
		return properties.getProperty(key, defaulValue);
	}

}
